package fr.curriculumvitae.anthony.stephan.utils;

import com.google.gson.Gson;

public class JsonSerializer {
	
	/**
	 * Serialize the given object to JSON format
	 * @param objectToSerialize
	 * @return JSON formatted String
	 */
	public static String serialize(Object objectToSerialize) {
		Gson gson = new Gson();
	    return gson.toJson(objectToSerialize);
	}

	/**
	 * Deserialize the given JSON formatted string to the given class object,
	 * @param jsonFormattedString
	 * @param classObject
	 * @return result object
	 */
	public static Object deserialize(String jsonFormattedString, Class<?> classObject) {
		Gson gson = new Gson();
		return gson.fromJson(jsonFormattedString, classObject);
	}

}
